import 'package:flutter_test/flutter_test.dart';
import 'package:image_preview/preview_data.dart';

void main() {
  // 测试PreviewData的创建和属性
  test('PreviewData 创建和属性测试', () {
    final previewData = PreviewData(
      type: Type.image,
      heroTag: 'test_tag',
      image: ImageData(
        url: 'https://example.com/image.jpg',
        path: '/local/path/image.jpg',
      ),
    );
    
    expect(previewData.type, Type.image);
    expect(previewData.heroTag, 'test_tag');
    expect(previewData.image?.url, 'https://example.com/image.jpg');
    expect(previewData.image?.path, '/local/path/image.jpg');
    expect(previewData.video, isNull);
  });

  // 测试PreviewData JSON序列化和反序列化
  test('PreviewData JSON序列化和反序列化测试', () {
    final previewData = PreviewData(
      type: Type.image,
      heroTag: 'test_tag',
      image: ImageData(
        url: 'https://example.com/image.jpg',
        thumbnailUrl: 'https://example.com/thumbnail.jpg',
      ),
    );
    
    // 序列化
    final jsonData = previewData.toJson();
    expect(jsonData['type'], 'image');
    expect(jsonData['heroTag'], 'test_tag');
    expect((jsonData['image'] as Map<String, dynamic>)['url'], 'https://example.com/image.jpg');
    
    // 反序列化
    final deserializedData = PreviewData.fromJson(jsonData);
    expect(deserializedData.type, Type.image);
    expect(deserializedData.heroTag, 'test_tag');
    expect(deserializedData.image?.url, 'https://example.com/image.jpg');
  });
}
